package vn.bus.controllers;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import vn.bus.service.StationService;

@Path("/json/station")
public class StationController {

	@GET
	@Path("all")
	public String getAllStations()
	{
		StationService stationsService = new StationService();
		return stationsService.getAllStationsJson();
	}
	
	@GET
	@Path("/textsearch/str={str}")
	public String textSearch(@PathParam("str") String str){
		if(str.length() >= 2){
			StationService stationsService = new StationService();
			return stationsService.getJsonTextSearch(str);
		}
		else
			return "Zero";
	}
	
	@GET
	@Path("/clicksearch/lat={lat}&lon={lon}")
	public String clickSearch(@PathParam("lat") double lat, @PathParam("lon") double lon){
		StationService stationsService = new StationService();
		return stationsService.getJsonClickSearch(lat, lon);
	}
}
